# -*- coding: utf-8 -*-
# @File    : get_base_info.py
# @Date    : 2021-11-16
# @Author  : Richard

import os
import time
import configparser


class Read_ini(object):
    def __init__(self):
        self.ini_file = "D:\PycharmProjects\oaProSQL\oa-pro-sql\conf\config.ini"
        self.sec = "dir"

    def get_values(self):
        """
        获取所有值
        :return: 返回对应的sec的values值
        """
        try:
            data = []
            cf = configparser.ConfigParser()
            cf.read(self.ini_file)
            options = cf.options(self.sec)
            for i in options:
                itmes = cf.get(self.sec, i)
                data.append(itmes)
            return data
        except Exception as Err:
            print("read config path_files error:{0}".format(Err))

    def values_by_key(self, sec):
        try:
            data = []
            cf = configparser.ConfigParser()
            cf.read(self.ini_file)
            options = cf.options(sec)
            for i in options:
                res = cf.get(sec, i)
                data.append(res)
            return data
        except Exception as Err:
            print("open file config error,file type is ini：{0}".format(Err))
